<script lang="ts" setup>
import { ref } from "vue";

defineOptions({
    name: "Child",
});
//--================= Data
let toy = ref("奥特曼11")

//--================= Methods
function go(value: any) {
    emit("test", value)
}

//--================= Other
//--- 声明事件

const emit = defineEmits(['test'])

</script>

<template>
    <div class="main2">
        <h4>子组件</h4>
        <h3>{{ toy }}</h3>
        <button @click="go(toy)">给父组件传值1</button>
        <button @click=" emit('test', toy)">给父组件传值2</button>

    </div>


</template>

<style scoped>
.main2 {
    background-color: skyblue;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
    min-height: 400px;
}
</style>
